function quickSort(arr){
    if(!arr.length) return []
    let left = []
    let right = []
    let povit = arr[0]
    for(let i = 1; i< arr.length; i++){
        if(arr[i] > povit){
            right.push(arr[i])
        } else {
            left.push(arr[i])
        }
    }
    return quickSort(left).concat(povit, quickSort(right))
}
console.log(quickSort([ 3, 4, 1, 5, 2 ]))


function insetSort(arr){
    for(let i = 1; i< arr.length; i++){
        let temp = arr[i]
        let j = i - 1;
        while(j >= 0 && arr[j] > temp){
            arr[j+1] = arr[j]
            j--
        }
        arr[j+1] = temp
    }
    return arr

}
console.log(insetSort([ 3, 4, 1, 5, 2 ]))